package com.qf.service.impl;

import com.qf.entity.GoodsDetail;
import com.qf.mapper.GoodsDetailMapper;
import com.qf.service.GoodsDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author lenovo
 * @version V1.0
 * @Date 2021/10/5 19:43
 */
@Service
public class GoodsDetailServiceImpl implements GoodsDetailService {

    @Autowired
    private GoodsDetailMapper goodsDetailMapper;

    @Override
    public List<GoodsDetail> findAll() {
        return goodsDetailMapper.findAll();
    }

    @Override
    public List<GoodsDetail> findAllBySortId(Integer id) {
        return goodsDetailMapper.findAllBySortId(id);
    }

    @Override
    @Transactional(rollbackFor = Throwable.class)
    public void add(GoodsDetail goodsDetail) {
        int i = goodsDetailMapper.insert(goodsDetail);
        if (i != 1){
            System.out.println("添加失败");
            throw new RuntimeException("添加失败");
        }
    }
}

